package com.excellence.service.impl;

import com.excellence.mapper.CropMapper;
import com.excellence.pojo.Crop;
import com.excellence.service.CropService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

/**
 * @author 沈秉璋
 * @ClassName CropServiceImpl
 * @Description TODO
 * @date 2024/4/8 10:49
 * @Version 1.0
 */
@Service
public class CropServiceImpl implements CropService {
    @Autowired
    CropMapper cropMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return cropMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Crop record) {
        record.setCreateTime(new Date());
        record.setUpdateTime(new Date());
        return cropMapper.insert(record);
    }

    @Override
    public int insertSelective(Crop record) {
        record.setCreateTime(new Date());
        record.setUpdateTime(new Date());
        return cropMapper.insertSelective(record);
    }

    @Override
    public List<Crop> selectByMassifId(Integer massifId) {
        return cropMapper.selectByMassifId(massifId);
    }

    @Override
    public List<Crop> selectAll() {
        return cropMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKeySelective(Crop record) {
        record.setUpdateTime(new Date());
        return cropMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Crop record) {
        record.setUpdateTime(new Date());
        return cropMapper.updateByPrimaryKey(record);
    }
}
